<script type="text/javascript">

function connectWebViewJavascriptBridge(callback) {
if (window.WebViewJavascriptBridge) {
    callback(WebViewJavascriptBridge)
} else {
    document.addEventListener('WebViewJavascriptBridgeReady', function() {
                              callback(WebViewJavascriptBridge)
                              }, false)
    }
}

function addPhotoTapEvent() {
    'use strict';
    var t = setTimeout(function() {
        var imgs = document.getElementsByTagName('img');
        for (var i in imgs) {
/*
           var p = imgs[i].parentNode;
           p.style.paddingLeft = "0px";
           p.style.paddingRight = "0px";
*/
           if (imgs[i].addEventListener) {
             new Tap(imgs[i]);
             imgs[i].addEventListener("tap",function() { window.location.href = this.src+"#piankePhotos"; },false);
           };
       };
    }, 10);
};

function changeFontSize(fontSize) {
    
    var title = document.getElementsByTagName('h1')[0];
    title.style['webkitTextSizeAdjust'] = fontSize;
    
    var p = document.getElementsByTagName('p');
    for (index in p) {
        if(p[index].style) {
            p[index].style['webkitTextSizeAdjust']=fontSize;
        };
    };
    
    var pre = document.getElementsByTagName('pre');
    for (index in pre) {
        if(pre[index].style) {
            pre[index].style['webkitTextSizeAdjust']= fontSize;
        };
    };
    
    
    connectWebViewJavascriptBridge(function(bridge) {
                                   bridge.send('font did change');
    });
    
    return 1;
};


/*!
 * tap.js
 * Copyright (c) 2013 Alex Gibson, http://alxgbsn.co.uk/
 * Released under MIT license
 */
(function (window, document) {

    'use strict';
 
    function Tap(el) {
        el = typeof el === 'object' ? el : document.getElementById(el);
        this.element = el;
        this.moved = false; //flags if the finger has moved
        this.startX = 0; //starting x coordinate
        this.startY = 0; //starting y coordinate
        this.hasTouchEventOccured = false; //flag touch event
        el.addEventListener('touchstart', this, false);
        el.addEventListener('touchmove', this, false);
        el.addEventListener('touchend', this, false);
        el.addEventListener('touchcancel', this, false);
        el.addEventListener('mousedown', this, false);
        el.addEventListener('mouseup', this, false);
    }

    Tap.prototype.start = function (e) {
        if (e.type === 'touchstart') {
            this.hasTouchEventOccured = true;
        }
        this.moved = false;
        this.startX = e.type === 'touchstart' ? e.touches[0].clientX : e.clientX;
        this.startY = e.type === 'touchstart' ? e.touches[0].clientY : e.clientY;
    };

    Tap.prototype.move = function (e) {
        //if finger moves more than 10px flag to cancel
        if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) {
            this.moved = true;
        }
    };

    Tap.prototype.end = function (e) {
        var evt;

        if (this.hasTouchEventOccured && e.type === 'mouseup') {
            e.preventDefault();
            e.stopPropagation();
            this.hasTouchEventOccured = false;
            return;
        }

        if (!this.moved) {
            //create custom event
            if (window.CustomEvent) {
                evt = new window.CustomEvent('tap', {
                    bubbles: true,
                    cancelable: true
                });
            } else {
                evt = document.createEvent('Event');
                evt.initEvent('tap', true, true);
            }
          
            // dispatchEvent returns false if any handler calls preventDefault,
            if (!e.target.dispatchEvent(evt)) {
                // in which case we want to prevent clicks from firing.
                e.preventDefault();
            }
        }
    };

    Tap.prototype.cancel = function (e) {
        this.hasTouchEventOccured = false;
        this.moved = false;
        this.startX = 0;
        this.startY = 0;
    };

    Tap.prototype.destroy = function () {
        var el = this.element;
        el.removeEventListener('touchstart', this, false);
        el.removeEventListener('touchmove', this, false);
        el.removeEventListener('touchend', this, false);
        el.removeEventListener('touchcancel', this, false);
        el.removeEventListener('mousedown', this, false);
        el.removeEventListener('mouseup', this, false);
        this.element = null;
    };

    Tap.prototype.handleEvent = function (e) {
        switch (e.type) {
        case 'touchstart': this.start(e); break;
        case 'touchmove': this.move(e); break;
        case 'touchend': this.end(e); break;
        case 'touchcancel': this.cancel(e); break;
        case 'mousedown': this.start(e); break;
        case 'mouseup': this.end(e); break;
        }
    };

    window.Tap = Tap;

}(window, document));

</script>